export default {
  install (Vue, options) {
    Vue.prototype.$initBtnStatus = function (evt) {
      if (!evt) return
      let target = evt.target;
      if(target.nodeName == "SPAN"){
          target = evt.target.parentNode;
      }
      target.blur();
    },
    Vue.prototype.$interceptFail = function (response) {
      let result = JSON.parse(response.result)
      // let result = response.result
      if (result.code == "fail") {
        this.$message({
          type: 'error',
          message: result.message,
          customClass: "my-message",
          duration: 1500,
        });
        return false
      }
      return true
    }
    // 成功消息
    Vue.prototype.$successMsg = function (content) {
      this.$message({
        type: 'success',
        message: content,
        customClass: "my-message",
        duration: 3000,
      });
    }
    // 错误消息
    Vue.prototype.$errorMsg = function (content) {
      this.$message({
        type: 'error',
        message: content,
        customClass: "my-message",
        duration: 4000,
      });
    }
    // 警告消息
    Vue.prototype.$warningMsg = function (content) {
      this.$message({
        type: 'warning',
        message: content,
        customClass: "my-message",
        duration: 1500,
      });
    }
  }
}